﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Tong;
public partial class GriView隔行变色 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    /// <summary>
    /// 鼠标移上去表格背景变色的效果
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void changeColor(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)//如果是行的话
        {
            e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='skyblue';");
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='';");
        }
    }
    //看看是不是要删除数据
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {

        if (e.Row.RowType == DataControlRowType.DataRow)
        {

            LinkButton l = (LinkButton)e.Row.FindControl("LinkButton1");

            l.Attributes.Add("onclick", "javascript:return " +

            "confirm('Are you sure you want to delete this record " +

            DataBinder.Eval(e.Row.DataItem, "bookid") + "')");

        }

    }




    //DataGrid操作時的確認對話框
    protected void changedd(object source, DataGridItemEventArgs e)
    {

        LinkButton DelButton = new LinkButton();
        if ((e.Item.ItemType == ListItemType.AlternatingItem) || (e.Item.ItemType == ListItemType.Item))
        {
            DelButton = (LinkButton)e.Item.Cells[0].FindControl("btdel");
            DelButton.Attributes.Add("onclick", "return confirm('您确定删除该条记录吗?');");
        }

    }


}
